//
//  AddBookViewModel.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 03.04.25.
//

import Foundation
class AddBookViewModel : KoiAccountingBaseViewModel {
    
    @Published var saveState = ""
    
    private let bookDao = KoiAccountingDB.standard.getBookDao()
    
    func save(bookName:String, bookColor: String, bookRemark: String?) {
        let book = AccountingBook(bookName: bookName, bookColor: bookColor, bookRemark: bookRemark, uid: uid)
        asyncBackground {
            self.bookDao.save(book: book)
            self.asyncMain {
                self.saveState = "success"
            }
        }
    }
}
